<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>/home/julien/Cours/programmation/test reseau/libreseau.h</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="Code::Blocks Exporter plugin" />
<style type="text/css">
<!--
body { color: #000000; background-color: #FFFFFF; }
.style1 { color: #A0A0A0; }
.style2 { color: #A0A0A0; }
.style3 { color: #8080FF; font-weight: bold; }
.style15 { color: #8080FF; font-weight: bold; }
.style17 { color: #008080; }
.style18 { color: #800000; }
.style4 { color: #F000F0; }
.style5 { color: #0000A0; font-weight: bold; }
.style16 { color: #00A000; font-weight: bold; }
.style6 { color: #0000FF; }
.style12 { color: #0000FF; }
.style7 { color: #E0A000; }
.style8 { color: #000000; }
.style9 { color: #00A000; }
.style10 { color: #FF0000; }
.style34 { color: #000000; background-color: #80FFFF; font-weight: bold; }
.style35 { color: #FFFFFF; background-color: #FF0000; font-weight: bold; }
--></style></head>
<body>
<pre>
<code><span style="font: 8pt Courier New;"><span class="style2">//------------------------------------------------------//
// libreseau.h
// librairie réseau
//-----------------------------------------------------//
// Auteur : Brondino Julien
// Date de dernière modification : 04-04-2007
//-----------------------------------------------------//
</span><span class="style9">#ifndef LIBRESEAU_H_INCLUDED
#define LIBRESEAU_H_INCLUDED

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;sys/wait.h&gt;

</span><span class="style1">/* Fonctions Serveur */
</span><span class="style5">int </span><span class="style11">creer_serveur_tcp </span><span class="style10">(</span><span class="style5">int </span><span class="style11">port</span><span class="style10">, </span><span class="style5">int </span><span class="style11">max_client</span><span class="style10">, </span><span class="style5">int </span><span class="style11">debug</span><span class="style10">);    </span><span class="style2">// Créer un serveur sur le port avec un nombre max de clients
</span><span class="style5">int </span><span class="style11">attendre_client_tcp </span><span class="style10">(</span><span class="style5">int </span><span class="style11">socket_serveur</span><span class="style10">, </span><span class="style5">int </span><span class="style11">debug</span><span class="style10">);        </span><span class="style2">// Attend un client sur le serveur

</span><span class="style1">/* Fonctions Client */
</span><span class="style5">int </span><span class="style11">creer_client_tcp </span><span class="style10">( </span><span class="style5">char </span><span class="style10">* </span><span class="style11">adresse</span><span class="style10">, </span><span class="style5">int </span><span class="style11">port</span><span class="style10">, </span><span class="style5">int </span><span class="style11">debug</span><span class="style10">);    </span><span class="style2">// Se connecte au serveur adresse:port

</span><span class="style1">/* Fonction de dialogue */
</span><span class="style5">int </span><span class="style11">ecrire</span><span class="style10">(</span><span class="style5">int </span><span class="style11">sockfd</span><span class="style10">, </span><span class="style5">char </span><span class="style10">* </span><span class="style11">message</span><span class="style10">);    </span><span class="style2">// Doit se terminer par \0
</span><span class="style5">int </span><span class="style11">lire</span><span class="style10">(</span><span class="style5">int </span><span class="style11">sockfd</span><span class="style10">, </span><span class="style5">char </span><span class="style10">* </span><span class="style11">message</span><span class="style10">, </span><span class="style5">int </span><span class="style11">maxChar</span><span class="style10">);            </span><span class="style2">// Se terminera par \0

</span><span class="style9">#endif </span><span class="style2">// LIBRESEAU_H_INCLUDED
</span></span>
</code></pre>
</body>
</html>
